<%@ page import="java.util.regex.*" %><%--

  Created by IntelliJ IDEA.
  User: gz
  Date: 2025/02/16
  Time: 22:48
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <script type="text/javascript">
        function check(){
            var num1 = document.getElementById("num1").value;
            var num2 = document.getElementById("num2").value;
            var regStr=/^-?\d+(\.\d+)?$/
            if(!(regStr.test(num1)&&regStr.test(num2))){
                alert("输入错误，请重新输入");
                return false
            }else {
                return true
            }
        }
    </script>
</head>
<body>
<form action="calServlet" method="get" onsubmit="return check()">
    <h1>JSP版本计算器</h1>
    num1:<input type="text" id="num1" name="num1"><br><br>
    num2:<input type="text" id="num2" name="num2"><br>
  请选择符号:  <select name="oper">
        <option value="+">+</option>
        <option value="-">-</option>
    </select><br><br>
    <input type="submit" value="提交">
</form>

</body>
</html>
